package com.t216.dm216.controller;

import com.t216.dm216.common.Result;
import com.t216.dm216.pojo.DmItem;
import com.t216.dm216.pojo.DmScheduler;
import com.t216.dm216.pojo.DmSchedulerSeatPrice;
import com.t216.dm216.pojo.dto.DmItemDTO;
import com.t216.dm216.pojo.dto.DmItemDetailDTO;
import com.t216.dm216.pojo.dto.DmItemTypeFloorDTO;
import com.t216.dm216.service.DmItemCommentService;
import com.t216.dm216.service.DmItemService;
import com.t216.dm216.service.DmSchedulerSeatPriceService;
import com.t216.dm216.service.DmSchedulerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/item/api/p")
public class DmItemController {
    @Resource
    private DmItemService dmItemService;

    @Resource
    private DmSchedulerService dmSchedulerService;

    @Resource
    private DmItemCommentService dmItemCommentService;
    @Resource
    private DmSchedulerSeatPriceService dmSchedulerSeatPriceService;

    @PostMapping("/queryItemLike")
    public Result<List<DmItemDTO>> queryItemLike(@RequestBody DmItemTypeFloorDTO itemTypeFloorDTO){
        return Result.success(dmItemService.getLikeItems(itemTypeFloorDTO.getItemTypeId()));
    }

    @PostMapping("/queryItemDetail")
    public Result<DmItemDetailDTO> queryItemDetail(@RequestBody DmItem item){
        return Result.success(dmItemService.getItemDetailById(item.getId()));
    }

    @PostMapping("/queryItemScheduler")
    public Result queryItemScheduler(@RequestBody DmScheduler scheduler){
        return Result.success(dmSchedulerService.getSchedulerByItemId(scheduler.getItemId()));
    }
    @PostMapping("/queryItemPrice")
    public Result queryItemPrice(@RequestBody DmSchedulerSeatPrice seatPrice){
        return Result.success(dmSchedulerSeatPriceService.getItemPriceByScheduleId(seatPrice.getScheduleId()));
    }

    @PostMapping("/queryItemComment")
    public Result queryItemComment(@RequestBody DmItem item){
        return Result.success(dmItemCommentService.getCommentsByItemId(item.getId()));

    }
}
